package com.tlibrary.service;

import com.tlibrary.dao.MultiplechoiceMapper;
import com.tlibrary.model.MultiplechoiceWithBLOBs;
import com.tlibrary.util.ShowpaperUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;

/**
 * @Author：wcc
 * @Description：
 * @Date：Create in: 2019/1/3--20:24
 */
@Service
public class ShowService {

    @Autowired
    private MultiplechoiceMapper mm;
    @Autowired
    private ShowpaperUtil showpaperUtil;
    /**
     * 通过id获得一道选择题
     * @param id
     * @return
     */
    public MultiplechoiceWithBLOBs getMultipleChoice(String id) {

        MultiplechoiceWithBLOBs multiplechoiceWithBLOBs = mm.selectByPrimaryKey(id);
        List<HashMap> list= MultiplechoiceWithBLOBstoList(multiplechoiceWithBLOBs);
        return multiplechoiceWithBLOBs;
    }

    private List<HashMap> MultiplechoiceWithBLOBstoList(MultiplechoiceWithBLOBs multiplechoiceWithBLOBs) {
        multiplechoiceWithBLOBs.getPica();

        String a = multiplechoiceWithBLOBs.getA();
        HashMap mapa=getMultipleChoices(a);
        String b = multiplechoiceWithBLOBs.getB();
        String c = multiplechoiceWithBLOBs.getC();
        String d = multiplechoiceWithBLOBs.getD();
        String e=multiplechoiceWithBLOBs.getE();
        String f = multiplechoiceWithBLOBs.getF();
        List<HashMap> list = null;
        return list;
    }

    private HashMap getMultipleChoices(String a) {

            HashMap hashMap=null;
            return hashMap;
    }

    public List<MultiplechoiceWithBLOBs> getMultipleChoice(HttpServletRequest request) {
        HttpSession session=request.getSession();
        String id = session.getAttribute("id").toString();
        List<MultiplechoiceWithBLOBs> multiplechoiceWithBLOBs = mm.selectByuser(id);
        return multiplechoiceWithBLOBs;
    }
}
